package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsIncome;
import com.yidu.ruifeng_logistics.dao.LogisticsIncomeDao;
import com.yidu.ruifeng_logistics.service.LogisticsIncomeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 收入表(LogisticsIncome)表服务实现类
 *
 * @author makejava
 * @since 2021-03-09 14:24:39
 */
@Service("logisticsIncomeService")
public class LogisticsIncomeServiceImpl implements LogisticsIncomeService {
    @Resource
    private LogisticsIncomeDao logisticsIncomeDao;

    /**
     * 通过ID查询单条数据
     *
     * @param incomeId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsIncome queryById(Integer incomeId) {
        return this.logisticsIncomeDao.queryById(incomeId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsIncome> queryAllByLimit(int offset, int limit) {
        return this.logisticsIncomeDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsIncome 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsIncome insert(LogisticsIncome logisticsIncome) {
        this.logisticsIncomeDao.insert(logisticsIncome);
        return logisticsIncome;
    }

    /**
     * 修改数据
     *
     * @param logisticsIncome 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsIncome update(LogisticsIncome logisticsIncome) {
        this.logisticsIncomeDao.update(logisticsIncome);
        return this.queryById(logisticsIncome.getIncomeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param incomeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer incomeId) {
        return this.logisticsIncomeDao.deleteById(incomeId) > 0;
    }

    @Override
    public List<LogisticsIncome> queryAll(LogisticsIncome logisticsIncome) {
        return this.logisticsIncomeDao.queryAll(logisticsIncome);
    }

}
